package com.jisuan.contract.controller;

import com.jisuan.contract.common.utils.PageResult;
import com.jisuan.contract.common.utils.Result;
import com.jisuan.contract.entity.SchoolContractEntity;
import com.jisuan.contract.service.SchoolContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 合同表
 *
 * @author 王大军
 * @email wangdajunzy@163.com
 * @date 2022-01-07 12:05:38
 */
@RestController
@RequestMapping("contract/contract")
public class SchoolContractController {
    @Autowired
    private SchoolContractService schoolContractService;

    /**
     * 列表
     */
    @GetMapping
    public Result<PageResult> list(@RequestParam Map<String, Object> params,
                                   SchoolContractEntity contract)
    {
        PageResult pageResult = schoolContractService.queryPage(params, contract);

        return Result.success(pageResult);
    }

    /**
     * 信息
     */
    @GetMapping("/{id}")
    public Result<SchoolContractEntity> info(@PathVariable("id") Long id)
    {
        SchoolContractEntity schoolContract = schoolContractService.getById(id);
        return Result.success(schoolContract);
    }

    /**
     * 保存
     */
    @PostMapping
    public Result<?> save(@RequestBody SchoolContractEntity schoolContract)
    {
        schoolContractService.save(schoolContract);
        return Result.success();
    }

    /**
     * 修改
     */
    @PutMapping
    public Result<?> update(@RequestBody SchoolContractEntity schoolContract)
    {
        schoolContractService.updateById(schoolContract);
        return Result.success();
    }

    /**
     * 删除
     */
    @DeleteMapping
    public Result<?> delete(@RequestBody Long[] ids)
    {
        schoolContractService.removeByIds(Arrays.asList(ids));
        return Result.success();
    }

}
